irq_exit();
}
+#ifndef XEN
#ifdef CONFIG_HOTPLUG_CPU
/*
* This function emulates a interrupt processing when a cpu is about to be
irq_exit();
}
#endif
+#endif
#ifdef CONFIG_SMP
#ifndef XEN
.global ia64_sal_to_os_handoff_state
.global ia64_os_to_sal_handoff_state
- .global ia64_do_tlb_purge
#endif
+ .global ia64_do_tlb_purge
.text
.align 16
* 04/11/17 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support
*/
#ifdef XEN
+#include <linux/cpu.h>
+#include <linux/notifier.h>
#include <xen/types.h>
#include <xen/lib.h>
#include <xen/symbols.h>
#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/unwind.h>
+#include <asm/sal.h>
#else
#define __KERNEL_SYSCALLS__ /* see <asm/unistd.h> */
#include <linux/config.h>
else
cpu_relax();
}
+#endif
#ifdef CONFIG_HOTPLUG_CPU
/* We don't actually take CPU down, just spin without interrupts. */
+#ifndef XEN
static inline void play_dead(void)
+#else
+void play_dead(void)
+#endif
{
extern void ia64_cpu_local_tick (void);
unsigned int this_cpu = smp_processor_id();
max_xtp();
local_irq_disable();
- idle_domain_exit();
ia64_jump_to_sal(&sal_boot_rendez_state[this_cpu]);
/*
* The above is a point of no-return, the processor is
BUG();
}
#else
+#ifndef XEN
static inline void play_dead(void)
+#else
+void play_dead(void)
+#endif
{
BUG();
}
#endif /* CONFIG_HOTPLUG_CPU */
+#ifndef XEN
void cpu_idle_wait(void)
{
unsigned int cpu, this_cpu = get_cpu();
static void __init
set_smp_redirect (int flag)
{
-#ifndef CONFIG_HOTPLUG_CPU
+#if defined(CONFIG_HOTPLUG_CPU) && !defined(XEN)
if (no_int_routing)
smp_int_redirect &= ~flag;
else
__setup("nointroute", nointroute);
+static void fix_b0_for_bsp(void)
+{
+#ifdef CONFIG_HOTPLUG_CPU
+ int cpuid;
+ static int fix_bsp_b0 = 1;
+
+ cpuid = smp_processor_id();
+
+ /*
+ * Cache the b0 value on the first AP that comes up
+ */
+ if (!(fix_bsp_b0 && cpuid))
+ return;
+
+ sal_boot_rendez_state[0].br[0] = sal_boot_rendez_state[cpuid].br[0];
+ printk ("Fixed BSP b0 value from CPU %d\n", cpuid);
+
+ fix_bsp_b0 = 0;
+#endif
+}
+
void
sync_master (void *arg)
{
BUG();
}
+ fix_b0_for_bsp();
+
lock_ipi_calllock();
cpu_set(cpuid, cpu_online_map);
unlock_ipi_calllock();
for (cpu = 0; cpu < NR_CPUS; cpu++) {
ia64_cpu_to_sapicid[cpu] = -1;
+#ifndef XEN
#ifdef CONFIG_HOTPLUG_CPU
cpu_set(cpu, cpu_possible_map);
+#endif
#endif
}
__u8 valid;
} mt_info[NR_CPUS] __devinitdata;
-#ifdef CONFIG_HOTPLUG_CPU
+#if defined(XEN) && !defined(CONFIG_HOTPLUG_CPU)
static inline void
remove_from_mtinfo(int cpu)
{
remove_siblinginfo(cpu);
cpu_clear(cpu, cpu_online_map);
+#ifndef XEN
fixup_irqs();
+#endif
local_flush_tlb_all();
cpu_clear(cpu, cpu_callin_map);
return 0;
}
+#else /* !CONFIG_HOTPLUG_CPU */
+int __cpu_disable(void)
+{
+ return -ENOSYS;
+}
+#endif /* CONFIG_HOTPLUG_CPU */
+#ifdef CONFIG_HOTPLUG_CPU
void __cpu_die(unsigned int cpu)
{
unsigned int i;
printk ("CPU %d is now offline\n", cpu);
return;
}
+#ifdef XEN
+ /* XXX: There must be a better way to sleep */
+ for (int j = 0; j < 1000000; j++)
+ cpu_relax();
+#else
msleep(100);
+#endif
}
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
}
#else /* !CONFIG_HOTPLUG_CPU */
-int __cpu_disable(void)
-{
- return -ENOSYS;
-}
-
void __cpu_die(unsigned int cpu)
{
/* We said "no" in __cpu_disable */
#include <xen/guest_access.h>
#include <asm/tlb_track.h>
#include <asm/perfmon.h>
+#include <asm/sal.h>
#include <public/vcpu.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
/* dom0_size: default memory allocation for dom0 (~4GB) */
static unsigned long __initdata dom0_size = 4096UL*1024UL*1024UL;
local_irq_enable();
}
+extern void play_dead(void);
+
static void continue_cpu_idle_loop(void)
{
+ int cpu = smp_processor_id();
+
for ( ; ; )
{
#ifdef IA64
irq_stat[cpu].idle_timestamp = jiffies;
#endif
page_scrub_schedule_work();
- while ( !softirq_pending(smp_processor_id()) )
+ while ( !softirq_pending(cpu) )
default_idle();
raise_softirq(SCHEDULE_SOFTIRQ);
do_softirq();
+ if (!cpu_online(cpu))
+ play_dead();
}
}
#include <asm/meminit.h>
#include <asm/hw_irq.h>
#include <asm/kexec.h>
+#include <linux/cpu.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
typedef asmlinkage NORET_TYPE void (*relocate_new_kernel_t)(
unsigned long indirection_page,
BUG();
}
-void machine_kexec(xen_kexec_image_t *image)
+#if CONFIG_SMP
+/* Need to implement some subset of hotplug-cpu - enough to
+ * send a cpu into rendevouz */
+
+/* N.B: The tasks frozen parameter can probably be dropped
+ * This can probably be rolled into cpu_down
+ */
+static int _cpu_down(unsigned int cpu, int tasks_frozen)
+{
+ if (num_online_cpus() == 1)
+ return -EBUSY;
+
+ if (!cpu_online(cpu))
+ return -EINVAL;
+
+#ifndef XEN
+ /* XXX: What, if anything, should Xen do here? */
+ /* Ensure that we are not runnable on dying cpu */
+ old_affinity = current->cpus_allowed;
+ tmp = CPU_MASK_ALL;
+ cpu_clear(cpu, tmp);
+ set_cpus_allowed(current, tmp);
+#endif
+
+ cpu_clear(cpu, cpu_online_map);
+
+ __cpu_die(cpu);
+
+ return 0;
+}
+
+static int cpu_down(unsigned int cpu)
{
+ int err;
+
+ /* Unlike Linux there is no lock, as there are no other callers
+ * and no other CPUS. */
+ err = _cpu_down(cpu, 0);
+
+ return 0;
+}
+#endif /* SMP */
+
+/* This should probably be an arch-hook called from kexec_exec()
+ * Its also likely that it should be in the xen equivalent of
+ * arch/ia64/kernel/process.c */
+static void machine_shutdown(void)
+{
+#ifdef CONFIG_SMP
+ unsigned int cpu;
+
+ for_each_online_cpu(cpu) {
+ if (cpu != smp_processor_id())
+ cpu_down(cpu);
+ }
+#endif
kexec_disable_iosapic();
+}
+
+void machine_kexec(xen_kexec_image_t *image)
+{
+ machine_shutdown();
unw_init_running(ia64_machine_kexec, image);
for(;;);
}
#ifdef CONFIG_XEN_SMP
#define CONFIG_SMP 1
+#define CONFIG_HOTPLUG_CPU 1
#define NR_CPUS 64
#define CONFIG_NUMA
#define CONFIG_ACPI_NUMA
+++ /dev/null
-/* This file is intentionally left empty. */
device.h -> linux/include/linux/device.h
# The files below are from Linux-2.6.21
+cpu.h -> linux/include/linux/cpu.h
efi.h -> linux/include/linux/efi.h
--- /dev/null
+#ifndef _ASM_IA64_CPU_H_
+#define _ASM_IA64_CPU_H_
+
+#include <linux/device.h>
+#include <linux/cpu.h>
+#include <linux/topology.h>
+#include <linux/percpu.h>
+
+#ifndef XEN
+struct ia64_cpu {
+ struct cpu cpu;
+};
+
+DECLARE_PER_CPU(struct ia64_cpu, cpu_devices);
+#endif
+
+DECLARE_PER_CPU(int, cpu_state);
+
+#ifndef XEN
+extern int arch_register_cpu(int num);
+#ifdef CONFIG_HOTPLUG_CPU
+extern void arch_unregister_cpu(int);
+#endif
+#endif
+
+#endif /* _ASM_IA64_CPU_H_ */